$.fn.adaptive = function(width,height,callback){
	var originalWidth = $(this).width(),
	originalHeight = $(this).height();
	
	$(this).load(function(){
		console.log('loaded');
		
		originalWidth = $(this).width();
		originalHeight = $(this).height();
		
		if(originalWidth > width || originalHeight > height){
			if(originalWidth/originalHeight > width/height){
				$(this).width(width);
				$(this).css('margin-top',(height - $(this).height())/2+'px');
				$(this).css('margin-left','0px');
			}else{
				$(this).height(height);
				$(this).css('margin-left',(width - $(this).width())/2+'px');
				$(this).css('margin-top','0px');
			}
		}else{
			$(this).css('margin-top',(height - originalHeight)/2+'px');
			$(this).css('margin-left',(width - originalWidth)/2+'px');
		}
		
		(callback||function(){})(originalWidth,originalHeight);
	});
};